import React,{Component} from "react";

export default class NotFound extends Component{
    constructor(props){
        super(props);
    }

    //用户点击类似关键字
    takeAdvice(event){
        let val = event.target.innerHTML;
        this.props.onRef();
    }

    //提交建议
    enterHandle(){
        location.replace("#/suggest/");
    }

    render(){
        let {isShow} = this.props;
        let showClass = isShow ? "show" : "hidden";
        let {data} = this.props;
        let similar = data.map((elt,i)=>{
            return ( <a href="javascript:;" onClick={this.takeAdvice.bind(this)} key={i}>{elt}</a> )
        });

        return (
            <div className={`${showClass} notFound`}>
                <div className="wrapper">
                    <span></span>
                    <p>抱歉！没有找到符合条件的内容。<br/>您可以尝试更换关键词</p>
                    <div>{similar}</div>
                    <button onClick={this.enterHandle.bind(this)}>提交建议</button>
                </div>
            </div>
        )
    }
}